package cn.bgs.controller;

import cn.bgs.service.EmanagmentService;
import cn.bgs.service.ManagerService;
import cn.bgs.utils.R;
import cn.bgs.vo.Pagevo;
import cn.bgs.vo.testVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/controllerm")
public class EmanagementController {
    @Autowired
    EmanagmentService emanagmentService;

    @PostMapping("manage")
    public PageInfo<testVo> selectEm(@RequestBody Pagevo pagevo) {
        PageInfo<testVo> page = emanagmentService.page4(pagevo);
        return page;
    }
    @PostMapping("updateEm")
    public R update(@RequestBody testVo form){
        System.out.println(form);
        emanagmentService.UpdateEmang(form);
        emanagmentService.updateOper(form);
        if (form!=null){
           return R.ok();
        }else{
          return  R.error();
        }
    }
    @DeleteMapping("{userId}")
    public R deleEm(@PathVariable Integer userId){
        emanagmentService.delEm(userId);
        if(userId!=null){
            return R.ok();
        }else{
            return R.error();
        }
    }

}
